<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<link rel="stylesheet" href="css/amazeui.min.css" tppabs="http://yanshi.sucaihuo.com/modals/16/1608/demo/css/amazeui.min.css" type="text/css" />
		<link rel="stylesheet" href="css/style.css" tppabs="http://yanshi.sucaihuo.com/modals/16/1608/demo/css/style.css" type="text/css" />
	</head>
	<body>
    <header data-am-widget="header" class="am-header am-header-default jz">
      <div class="am-header-left am-header-nav">
         <a href="javascript:history.back()" class="">
			<i class="am-icon-chevron-left"></i>
		</a>
      </div>
      <h1 class="am-header-title">
          <a href="#title-link" class="">业主圈</a>
      </h1>
      <div class="am-header-right am-header-nav">
         <a href="sendMsg.html" class="">
			发表
		</a>
      </div>
    </header>
	<div class="doc-example">
		<div style="margin-left: 15px;margin-top: 10px;">
			<span class="am-icon-refresh am-icon-sm" style="color: #C10802;"></span>
			<span style="font-family: '微软雅黑';font-weight: 800;">业主娱乐圈</span>
		</div>
		<ul class="am-comments-list am-comments-list-flip" id="lists">
			<!--<li class="am-comment">
				<a href="#link-to-user-home">
					<img src="images/logo.png" alt="" class="am-comment-avatar" width="48" height="48">
				</a>
				<div class="am-comment-main">
					<header class="am-comment-hd">
						<div class="am-comment-meta">
							<a href="#link-to-user" class="am-comment-author">路人甲</a> 说 <time datetime="2013-07-27T04:54:29-07:00" title="2013年7月27日 下午7:54 格林尼治标准时间+0800">2014-7-13 0:03</time></div>
					</header>
					<div class="am-comment-bd">
						<p>She's gone 我早知道<br>她将要 从我的生命中走掉<br>不再停留多一秒</p>
					</div>
				</div>
			</li>-->
		</ul>
	</div>
    <div style="height: 52px;"></div>
	<div data-am-widget="navbar" class="am-navbar  gm-foot am-no-layout" id="">
		<ul class="am-navbar-nav am-cf am-avg-sm-4">
			<li>
				<a href="index.html" class="curr">
					<span class="am-icon-home"></span>
					<span class="am-navbar-label">首页</span>
				</a>
			</li>
			<li>
				<a href="price.html" class="">
					<span class="am-icon-paypal"></span>
					<span class="am-navbar-label">报价</span>
				</a>
			</li>
			<li class="curr">
				<a href="yezhuquan.html" class="">
					<span class="am-icon-spinner"></span>
					<span class="am-navbar-label">业主圈</span>
				</a>
			</li>
			<li>
				<a href="main.html" class="">
					<span class="am-icon-user"></span>
					<span class="am-navbar-label">我的</span>
				</a>
			</li>
		</ul>
	</div>
	</body>
	<script type="text/javascript" src="js/jquery.min.js" tppabs="http://yanshi.sucaihuo.com/modals/16/1608/demo/js/jquery.min.js" ></script>
	<script type="text/javascript" src="js/amazeui.min.js" tppabs="http://yanshi.sucaihuo.com/modals/16/1608/demo/js/amazeui.min.js"></script>
	<script type="text/javascript" src="js/hui.js"></script>
	<script>
		var id = localStorage.getItem("id");
		if(!id){
			location.href="login.html";
		}else{
			hui.getJSON(
				rootpath + '/businessMan/findBusinessMan/' + id,
				function(msg) {
					console.log(msg);
					if(msg.isActive!=0){
						hui.toast('你已被管理员禁用，将无权限访问!', 'warn');
						localStorage.removeItem("id")
						location.href="login.html";
						return;
					}
				},
				function(e) {
					hui.iconToast('读取消息失败', 'warn');
					console.log(e);
				}
			);
			getLists();
		}
		$("#saves").click(function(){
			var contents = $(".ts").val();
          	if(!contents){
               hui.toast('内容不能为空!', 1000);
              return;
            }
			hui.postJSON(
			    rootpath+'/char/charAddSave/',
			    {
			    	content:contents,
			    	businessManId: id
			    },
			    function(msg){
			    	if(msg.result=="false"){
			    		hui.toast("发布失败!", 1000);
			    	}else{
			    		hui.toast("发布成功!", 1000);
			    	}
			    	$(".ts").val("");
			    	getLists();
			    },
			    function(e){
			        hui.iconToast('读取消息失败', 'warn');
			        console.log(e);
			    }
			);
		});
		function getLists(){
			hui.postJSON(
			    rootpath+'/char/charList/',
			    {
			    	pageSize:50,
			    	pageIndex: 1,
			    	searchVal:""
			    },
			    function(msg){
			    	var html = '<li class="am-comment" style="width:95%">';
			    	var all = "";
					html = html +'<a onclick="lookInfo(~);"><img src="~" alt="" class="am-comment-avatar" width="48" height="48"></a>';
					html = html +'<div class="am-comment-main">';
					html = html +'<header class="am-comment-hd">';
					html = html +'<div class="am-comment-meta">';
					html = html +'<a class="am-comment-author">~</a>  <time style="float:right">~</time></div>';
					html = html +'</header>';
					html = html +'<div class="am-comment-bd">';
					html = html +'<p>~</p>';
					html = html +'</div>';
					html = html +'</div>';
					html = html +'</li>';
			    	if(msg.total==0){
			    		$("#lists").html('<li><h4 align="center" style="margin-top:20px">暂无数据</h4></li>');
			    	}else{
			    		for(var i=0;i<msg.rows.length;i++){
		              	if(msg.rows[i].businessManVo.faceImg.indexOf("http")>-1){
		                		all = all + html.replace("~",msg.rows[i].businessManId).replace("~",msg.rows[i].businessManVo.faceImg).replace("~",msg.rows[i].businessManVo.hotelSinName).replace("~",getDates(msg.rows[i].createTime)).replace("~",msg.rows[i].content);
		                }else{
		    					all = all + html.replace("~",msg.rows[i].businessManId).replace("~",rootpath+"/"+msg.rows[i].businessManVo.faceImg).replace("~",msg.rows[i].businessManVo.hotelSinName).replace("~",getDates(msg.rows[i].createTime)).replace("~",msg.rows[i].content);
		                }
			    		}
			    		$("#lists").html(all);
			    	}
			    	
			    },
			    function(e){
			        hui.iconToast('读取消息失败', 'warn');
			        console.log(e);
			    }
			);
		}
      function lookInfo(val){
      	localStorage.removeItem("busid");
        localStorage.setItem("busid",val);
        location.href="businessMan.html";
      
      }
	</script>
</html>
